/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} head
 * @return {boolean}
 */
var hasCycle = function (head) {
    if (!head) return false;
    if (!head.next) return false;
    const obj = {}
    while (head) {
        if (obj['head'] !== undefined) return true;
        obj['head'] = head.val;
        head = head.next
    }
    return false;
};

function ListNode(val) {
    this.val = val;
    this.next = null;
}

// 测试数据
const head = new ListNode('a')
head.next = new ListNode('b')
head.next.next = new ListNode('c')
head.next.next.next = head
console.log(hasCycle(head));
